package com.achao.achaomq.config;

import com.achao.achaomq.constants.RocketMqConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * mq配置文件
 */
@Configuration
public class RocketMqConfig {

    @Autowired
    private RocketMqProductAdapter rocketMqProductAdapter;

    @Autowired
    private RocketMqConsumeAdapter rocketMqConsumeAdapter;


    //初始化生产者
    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate productionPackagingConfirmMqTemplate() {
        return rocketMqProductAdapter.getTemplateByTopicName(RocketMqConstant.ACHAO_TOPIC);
    }
}
